import router from "./index";
import useUserStore from "@/store/user";
router.beforeEach((to, from, next) => {
  const userStore = useUserStore();
  const pass = !!userStore.token;
  if ("/verify" === to.path) {
    if (pass) {
      next("/");
    } else {
      document.title = `vue3-template | ${to.meta.title}`;
      next();
    }
  } else {
    if (pass) {
      document.title = `vue3-template | ${to.meta.title}`;
      next();
    } else {
      next("/verify");
    }
  }
});
